/*
 * Package: org.grassfield.common.dao
 * FileName: AuditLogDAO.java
 *  
 * Created by pandian on Jan 28, 2011
 */
package dao;

import bean.AuditLog;

/**
 * The Class AuditLogDAO.
 */
public class AuditLogDAO extends BaseDAO implements IAuditLogDAO {

	/** The Constant FIELD_LENGTH. */
	private static final int FIELD_LENGTH = 255;

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.grassfield.common.dao.IAuditLogDAO#add(org.grassfield.common.entity.AuditLog)
	 */
	@Override
	public final AuditLog add(final AuditLog auditLog) {
		String message = auditLog.getMessage();
		if (message != null) {
			if (message.length() >= AuditLogDAO.FIELD_LENGTH) {
				message = message.substring(0, AuditLogDAO.FIELD_LENGTH);
				auditLog.setMessage(message);
			}
		}
		return (AuditLog) super.save(auditLog);
	}
}
